public class LeetCode_657 {
    public static void main(String[] args) {
        System.out.println(judgeCircle("UD"));
        System.out.println(judgeCircle("LL"));
    }

    public static boolean judgeCircle(String moves) {
        int row = 0;
        int column = 0;
        for (char c : moves.toCharArray()) {
            if(c == 'L') row--;
            else if(c == 'R') row++;
            else if(c == 'U') column++;
            else if(c == 'D') column--;
        }
        return row == 0 && column == 0;
    }
}
